home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
201-225
/
disk_222
/
plplot
/
src
/
source.zoo
/
plmtex.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-05-15
|
4KB
|
104 lines
/* Prints out "text" at specified position relative to viewport */
/* (may be inside or outside) */
/* side String which is one of the following: */
/* B or b : Bottom of viewport */
/* T or t : Top of viewport */
/* L or l : Left of viewport */
/* R or r : Right of viewport */
/* LV or lv : Left of viewport, vertical text */
/* RV or rv : Right of viewport, vertical text */
/* disp Displacement from specified edge of viewport, measured */
/* outwards from the viewport in units of the current */
/* character height. The CENTRELINES of the characters are */
/* aligned with the specified position. */
/* pos Position of the reference point of the string relative */
/* to the viewport edge, ranging from 0.0 (left-hand edge) */
/* to 1.0 (right-hand edge) */
/* just Justification of string relative to reference point */
/* just = 0.0 => left hand edge of string is at reference */
/* just = 1.0 => right hand edge of string is at reference */
/* just = 0.5 => centre of string is at reference */
#include "plplot.h"
void plmtex(side,disp,pos,just,text)
char side[], text[];
float disp, pos, just;
{
int clpxmi, clpxma, clpymi, clpyma;
int sppxmi, sppxma, sppymi, sppyma;
int vert, refx, refy;
float shift, xform[4];
float vpdxmi, vpdxma, vpdymi, vpdyma;
float chrdef, chrht;
float mpxscl, mpxoff, mpyscl, mpyoff;
int level;
glev(&level);
if (level < 2) fatal("Please set up viewport before calling PLMTEX.");
/* Open clip limits to subpage limits */
gclp(&clpxmi,&clpxma,&clpymi,&clpyma);
gspp(&sppxmi,&sppxma,&sppymi,&sppyma);
sclp(sppxmi,sppxma,sppymi,sppyma);
gvpd(&vpdxmi,&vpdxma,&vpdymi,&vpdyma);
gmp(&mpxscl,&mpxoff,&mpyscl,&mpyoff);
gchr(&chrdef,&chrht);
shift = 0.0;
if (just!=0.0) shift = just * plstrl(text);
if (strpos(side,'B')!=-1 || strpos(side,'b')!=-1) {
vert = 0;
refx = dcpcx(vpdxmi + (vpdxma-vpdxmi) * pos) - shift*mpxscl;
refy = mmpcy(dcmmy(vpdymi) - disp * chrht);
}
else if (strpos(side,'T')!=-1 || strpos(side,'t')!=-1) {
vert = 0;
refx = dcpcx(vpdxmi + (vpdxma-vpdxmi) * pos) - shift*mpxscl;
refy = mmpcy(dcmmy(vpdyma) + disp * chrht);
}
else if (stindex(side,"LV")!=-1 || stindex(side,"lv")!=-1) {
vert = 0;
refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos);
refx = mmpcx(dcmmx(vpdxmi) - disp * chrht - shift);
}
else if (stindex(side,"RV")!=-1 || stindex(side,"rv")!=-1) {
vert = 0;
refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos);
refx = mmpcx(dcmmx(vpdxma) + disp * chrht - shift);
}
else if (strpos(side,'L')!=-1 || strpos(side,'l')!=-1) {
vert = 1;
refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos) - shift*mpyscl;
refx = mmpcx(dcmmx(vpdxmi) - disp * chrht);
}
else if (strpos(side,'R')!=-1 || strpos(side,'r')!=-1) {
vert = 1;
refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos) - shift*mpyscl;
refx = mmpcx(dcmmx(vpdxma) + disp * chrht);
}
else {
sclp(clpxmi,clpxma,clpymi,clpyma);
return;
}
if (vert != 0) {
xform[0] = 0.0;
xform[1] = -1.0;
xform[2] = 1.0;
xform[3] = 0.0;
}
else {
xform[0] = 1.0;
xform[1] = 0.0;
xform[2] = 0.0;
xform[3] = 1.0;
}
plstr(0,xform,refx,refy,text);
sclp(clpxmi,clpxma,clpymi,clpyma);
}